package the.broccoli.setting.service.impl;

import org.springframework.transaction.annotation.Transactional;
import the.broccoli.setting.dto.FileCondition;
import the.broccoli.setting.entity.BroFile;
import the.broccoli.setting.mapper.FileMapper;
import the.broccoli.setting.service.IFileService;
import org.wisteria.framework.web.mvc.service.AbstractSuperService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 附件 服务实现类
 * </p>
 *
 * @author lei.liu
 * @since 2020-04-24
 */
@Service
public class FileServiceImpl extends AbstractSuperService<FileMapper, BroFile> implements IFileService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void deleteByTargetId(Integer fileCategory, String targetId, String modifiedId, String modifiedName) {
        baseMapper.deleteByTargetId(fileCategory, targetId, new Date(), modifiedId, modifiedName);
    }

    @Override
    public List<BroFile> selectByTargetId(Integer fileCategory, String targetId) {
        FileCondition fileCondition = new FileCondition();
        fileCondition.setFileCategory(fileCategory);
        fileCondition.setTargetId(targetId);
        return listByCondition(fileCondition);
    }
}
